package com.example.zuoye;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

import com.example.zuoye.Main3Activity.data.User;
import com.example.zuoye.Main3Activity.databinding.ActivityMainBinding;
public class Main3Activity extends AppCompatActivity {
   // ActivityMainBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        binding=DataBindingUtil.setContentView(this,R.layout.activity_main,null);
        User user=new User();
        user.setName("张琴");
        user.setSex("女");
        binding.setUser(user);

        setSupportActionBar(binding.tb);
        binding.tb.setNavigationIcon(R.mipmap.ic_launcher);
        binding.tb.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                switch (item.getItemId()){
                    case R.id.one:
                        Toast.makeText(MainActivity.this, "点击了第一个", Toast.LENGTH_SHORT).show();
                        Intent intent = new Intent(MainActivity.this,Main2Activity.class);
                        startActivity(intent);
                        break;
                    case R.id.two:
                        Toast.makeText(MainActivity.this, "点击了第二个", Toast.LENGTH_SHORT).show();
                        Intent intent1 = new Intent(MainActivity.this,Main2Activity.class);
                        startActivity(intent1);
                        break;
                    case R.id.three:
                        Toast.makeText(MainActivity.this, "点击了第三个", Toast.LENGTH_SHORT).show();
                        Intent intent2 = new Intent(MainActivity.this,Main2Activity.class);
                        startActivity(intent2);
                        break;
                }
                return true;}});}
    public boolean onCreateOptionsMenu(Menu menu){
        getMenuInflater().inflate(R.menu.item_toolbar,menu);
        return true;
    }

}
